<script>
    let _this;
	let keyHttpUrl = 'zcsoft_uni_partner_httpurl';
	let keySysCfg = 'zcsoft_uni_partner_sysconfig';
	export default {
		onLaunch: function() {
			_this = this;
			_this.doUpdate(); //小程序自动更新
			let desc = '';
			let wxSysConfig = uni.getStorageSync(keySysCfg);
			let PlateType = '';
			let httpUrl = '';
			// #ifdef MP-WEIXIN
			PlateType = 'WxMP';
			let IsCanSysInfo = uni.canIUse('getSystemInfoSync.return.screenWidth');
			if (IsCanSysInfo) {
				let curSystem = uni.getSystemInfoSync();
				_this.WxVersion = curSystem.version;
				let curVer = _this.doGetVer(_this.WxVersion);
				let serVer = _this.doGetVer('7.0.4');
				if(curVer < serVer) {
					_this.$ZcPublic.Err('你的微信版本太低，请升级到最新版本后再试!');
					return;
				}
				desc += '品牌:' + curSystem.brand;
				desc += ', 型号:' + curSystem.model;
				desc += ', 型号:' + curSystem.model;
				desc += ', 像素比:' + curSystem.pixelRatio;
				desc += ', 屏宽:' + curSystem.screenWidth;
	
				desc += ', 屏高:' + curSystem.screenHeight;
				desc += ', 系统版本:' + curSystem.system;
				desc += ', 微信版本:' + curSystem.version;
				desc += ', 平台:' + curSystem.platform;
			}
			if (wxSysConfig) {
				wxSysConfig = JSON.parse(wxSysConfig);
				uni.setStorageSync(keyHttpUrl, _this.$ZcPublic.Domain + 'UniService/doCustomService.ashx');
				_this.$ZcPublic.WaitModel = wxSysConfig.WaitModel;
				_this.$ZcPublic.IsErrLog = wxSysConfig.IsErrLog;
				_this.$ZcPublic.IsPerLog = wxSysConfig.IsPerLog;
				
				_this.$ZcPublic.CarKey = wxSysConfig.CarKey;
				_this.$ZcPublic.CarUrl = wxSysConfig.CarUrl;
			} 
			else {
				uni.setStorageSync(keyHttpUrl, _this.$ZcPublic.Domain + 'UniService/doCustomService.ashx');
			}
			httpUrl = uni.getStorageSync(keyHttpUrl);
			if (httpUrl) {
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: false,
					Paras: {
						Name: 'Uni_Config',
						Action: 'getCusCfg',
						Data: {
							Desc: desc
						}
					},
					Callback:_this.cbLaunch,
					Scope: _this
				});
			}
			// #endif
		},
		onShow: function() {},
		onHide: function() {},
		onError: function(err) {
			let me = this;
			try{
				let jsErrStr = JSON.stringify(err);
				let arErrStr = jsErrStr.split("\\n");
				if (arErrStr.length >= 5) {
					 let msg_1th = arErrStr[1].trim();
					 let msg_2th = arErrStr[2].trim();
					 let msg_3th = arErrStr[3].trim();
					 let msg_4th = arErrStr[4].trim();
					 let msg_page = ''; //找出错误页面名称
					 let msg_fn = ''; //找出出错的函数名
					 let msg_err = ''; //找出错误信息
					 if (msg_1th.indexOf('[Component]') >= 0) {
						 let ar_msg_page = msg_1th.split('@');
						 msg_page = ar_msg_page[1].trim();
						 msg_page = msg_page.replace('#handleEvent', '');
						 msg_page = '组件:' + msg_page.replace('#(anonymous)', '');
					 }
					 msg_2th = msg_2th.replace('SyntaxError: ', '');
					 msg_err = msg_2th.replace('Error: ', '');
	
					 if (msg_3th.indexOf('at VueComponent.') >= 0) {
						 msg_fn = msg_3th;
					 }
					 if (msg_4th.indexOf('at VueComponent.') >= 0) {
						 msg_fn = msg_4th;
					 }
					 if (msg_fn.length > 0) {
						 let ar_msg_fn = msg_fn.split('(');
						 msg_fn = ar_msg_fn[0].trim();
						 msg_fn = msg_fn.replace('at VueComponent.', '');
						 if(ar_msg_fn[1].indexOf('/pages/') >= 0) {
							 let ar_msg_page = ar_msg_fn[1].split('/pages/');
							 if(ar_msg_page[1].indexOf('.js:') >= 0) {
								 let ar_page = ar_msg_page[1].split('.js:');
								 msg_page += '页面:pages/' + ar_page[0] + '.vue';
							 }
						 } 
					 }
					 me.$ZcPublic.Server.Log(msg_page, msg_fn, msg_err, _this);
				}
			}
			catch(e){
			}
		},
		methods: {
			doGetVer: function (data) {
				let arrData = data.split('.');
				let arrD1 = arrData[0];
				let arrD2 = arrData[1];
				let arrD3 = arrData[2];
				if(arrD1.length < 2)
					arrD1 = '0' + arrData[0];
				if(arrD2.length < 2)
					arrD2 = '0' + arrData[1];
				if(arrD3.length < 2)
					arrD3 = '0' + arrData[2];
				let ver = parseInt(arrD1 + arrD2 + arrD3);
				return ver;
			},
			doUpdate: function() {
				try{
					// 获取小程序更新机制
					if (uni.canIUse('getUpdateManager')) {
					  const updateManager = uni.getUpdateManager();
					  updateManager.onCheckForUpdate(function (res) {
						if (res.hasUpdate) {
						  updateManager.onUpdateReady(function () {
							uni.showModal({
							  title: '更新提示',
							  content: '新版本已经准备好，重启应用才能生效？',
							  success: function (res) {
								if (res.confirm) {
								  updateManager.applyUpdate();
								}
							  }
							})
						  });
						  updateManager.onUpdateFailed(function () {
							uni.showModal({
							  title: '提示',
							  content: '更新失败，当前已是最新版本！请您删除当前小程序，重新搜索并打开!',
							});
						  });
						}
					  });
					}
				}
				catch(e){
					uni.showModal({
					  title: '更新提示',
					  content: '版本更新失败!',
					});
				}
			},
			cbLaunch: function(res,scope) {
				let curVer = _this.doGetVer(_this.WxVersion);
				let serVer = _this.doGetVer(res.data.RecAppVer);
				if(curVer < serVer) {
					//当前微信版本低于服务器指定的版本
					_this.$ZcPublic.Err('你的微信版本太低，请升级到最新版本后再试!');
					return;
				}
				_this.$ZcPublic.WaitModel = res.data.WaitModel;
				_this.$ZcPublic.IsErrLog = res.data.IsErrLog;
				_this.$ZcPublic.IsPerLog = res.data.IsPerLog;
				_this.$ZcPublic.CarKey = res.data.CarKey;
				_this.$ZcPublic.CarUrl = res.data.CarUrl;
				if(res.data.ClearAppCache == 'true') {
					let locUpVer = uni.getStorageSync('ClearAppVer');
					if(!locUpVer) {
						locUpVer = '0';
					}
					let intLocVer = parseInt(locUpVer);
					let intSerVer = parseInt(res.data.ClearAppVer);
					if(intLocVer < intSerVer) {
						uni.clearStorageSync();
						uni.setStorageSync('ClearAppVer', res.data.ClearAppVer);
					}
				}
				uni.setStorageSync(keyHttpUrl, _this.$ZcPublic.Domain + 'UniService/doCustomService.ashx');
				uni.setStorageSync(keySysCfg, JSON.stringify(res.data));
			}
		}
	}
</script>
<!-- <script>
	let _this;
	export default {
		onLaunch: function() {
			// 清除所有的缓存
			// #ifdef MP-WEIXIN
			// wx.clearStorage();
			// wx.clearStorageSync();
			// #endif

			_this = this;
			let desc = '';
			let keyHttpUrl = 'zcsoft_uni_partner_httpurl';
			let keySysCfg = 'zcsoft_uni_partner_sysconfig';
			let wxSysConfig = uni.getStorageSync(keySysCfg);
			let PlateType = '';
			let httpUrl = '';
			// #ifdef MP-WEIXIN

			PlateType = 'WxMP';
			let IsCanSysInfo = uni.canIUse('getSystemInfoSync.return.screenWidth');
			if (IsCanSysInfo) {
				let curSystem = uni.getSystemInfoSync();
				console.log('curSystem',curSystem);
				if(curSystem.system.indexOf("Android")>=0){
					console.log("安卓",curSystem.system);
					if(curSystem.version<"7.0.10"){
						console.log("微信版本过低");
						// uni.navigateTo({
						// 	url: '../pages/replaceVer/replaceVer'
						// });
						// return
					}
				}else if(curSystem.system.indexOf("Ios")>=0){
					console.log("ios",curSystem.system);
				}
				desc += '品牌:' + curSystem.brand;
				desc += ', 型号:' + curSystem.model;
				desc += ', 型号:' + curSystem.model;
				desc += ', 像素比:' + curSystem.pixelRatio;
				desc += ', 屏宽:' + curSystem.screenWidth;

				desc += ', 屏高:' + curSystem.screenHeight;
				desc += ', 系统版本:' + curSystem.system;
				desc += ', 微信版本:' + curSystem.version;
				desc += ', 平台:' + curSystem.platform;
			}
			if (wxSysConfig) {
				wxSysConfig = JSON.parse(wxSysConfig);
				uni.setStorageSync(keyHttpUrl, wxSysConfig.WxMpUrl);
				_this.$ZcPublic.Domain = wxSysConfig.Domain;
				_this.$ZcPublic.Modal = wxSysConfig.Modal;
				_this.$ZcPublic.CarUrl = wxSysConfig.CarUrl;
				_this.$ZcPublic.CarKey = wxSysConfig.CarKey;
				_this.$ZcPublic.IsWxDebug = wxSysConfig.IsWxDebug;
				uni.setStorageSync('key_partner_iswxdebug', wxSysConfig.IsWxDebug);
				uni.setStorageSync('key_partner_voitimes', wxSysConfig.VoiTimes);
				uni.setStorageSync('key_partner_voivibrt', wxSysConfig.VoiVibrt);
			} else {
				uni.setStorageSync(keyHttpUrl, _this.$ZcPublic.Domain + 'UniService/doPageService.ashx');
			}
			httpUrl = uni.getStorageSync(keyHttpUrl);
			if (httpUrl) {
				console.log('httpUrl',httpUrl);
				httpUrl = httpUrl + '?IsNeedLogin=false&dc=' + new Date().getTime();
				uni.request({
					url: httpUrl,
					data: {
						Name: 'Uni_Config',
						Action: 'getConfig',
						Data: {
							Desc: desc
						}
					},
					method: "POST",
					dataType: "json",
					success: function(response) {
						console.log('获取基本信息',response);
						if (response.statusCode === 200) {
							let wxRes = response.data;
							// _this.$ZcPublic.Domain = wxRes.data.Domain;
							// _this.$ZcPublic.Modal = wxRes.data.Modal;
							// _this.$ZcPublic.CarUrl = wxRes.data.CarUrl;
							// _this.$ZcPublic.CarKey = wxRes.data.CarKey;
							// _this.$ZcPublic.IsWxDebug = wxRes.data.IsWxDebug;
							console.log('wxRes.data', wxRes.data);
							if(uni.getStorageSync('AppVer') &&  parseInt(uni.getStorageSync('AppVer'))<parseInt(wxRes.data.AppVer)){
								console.log('wxRes.data.ClearAppCache',wxRes.data.ClearAppCache);
								if(wxRes.data.ClearAppCache == "true"){
									console.log("测试登录清除缓存成功！");
									uni.clearStorage();
									uni.clearStorageSync();
							  };
							}
							uni.setStorageSync(keyHttpUrl, _this.$ZcPublic.Domain);
							uni.setStorageSync('key_partner_iswxdebug', wxRes.data.IsWxDebug);
							uni.setStorageSync(keySysCfg, JSON.stringify(wxRes.data));
							uni.setStorageSync('key_partner_voitimes', wxRes.data.VoiTimes);
							uni.setStorageSync('key_partner_voivibrt', wxRes.data.VoiVibrt);
							uni.setStorageSync('AppVer', wxRes.data.AppVer);
						} else {
							uni.showModal({
								title: '警告',
								content: '网络超时，系统初始化失败!',
								showCancel: false
							});
						}
					},
					fail: function(response) {
						if (response.errMsg) {
							if (response.errMsg.toLowerCase().trim() === 'request:fail') {
								uni.showModal({
									title: '警告',
									content: '已断网，系统初始化失败!',
									showCancel: false
								});
							}
						}
					}
				});
			}
			// #endif

			// #ifdef H5
			PlateType = 'H5';
			if (wxSysConfig) {
				wxSysConfig = JSON.parse(wxSysConfig);
				uni.setStorageSync(keyHttpUrl, wxSysConfig.VueUrl);
				_this.$ZcPublic.Domain = wxSysConfig.Domain;
			} else {
				uni.setStorageSync(keyHttpUrl, _this.$ZcPublic.Domain + 'UniService/doVueService.ashx');
			}
			httpUrl = uni.getStorageSync(keyHttpUrl);
			if (_this.$ZcPublic.Server.IsDebug == true || _this.$ZcPublic.Server.IsDebug == 'true') {
				httpUrl = httpUrl + '?IsDebug=true&IsNeedLogin=false&dc=' + new Date().getTime();
			} else {
				httpUrl = httpUrl + '?IsDebug=false&IsNeedLogin=false&dc=' + new Date().getTime();
			}
			console.log("httpUrl",httpUrl);
			_this.$ZcPublic.Http.post(httpUrl, JSON.stringify({
					Name: 'Uni_Config',
					Action: 'getInitConfig',
					Data: {}
				}), {
					withCredentials: true
				})
				.then(function(response) {
					if (response.status === 200) {
						let wxRes = response.data;
						_this.$ZcPublic.Domain = wxRes.data.Domain;
						_this.$ZcPublic.Modal = wxRes.data.Modal;
						_this.$ZcPublic.CarUrl = wxRes.data.CarUrl;
						_this.$ZcPublic.CarKey = wxRes.data.CarKey;
						_this.$ZcPublic.IsWxDebug = wxRes.data.IsWxDebug;
						uni.setStorageSync('key_partner_iswxdebug', wxSysConfig.IsWxDebug);
						console.log('H5:wxRes', response.data);
					} else {
						uni.showModal({
							title: '警告',
							content: '网络超时，系统初始化失败!',
							showCancel: false
						});
					}
				})
				.catch(function(err) {});
			// #endif

			// end
		},
		onShow: function() {},
		onHide: function() {},
		onError: function(err) {
			uni.showToast({
				title: err.message,
				position: 'center',
				duration: 3000
			});
			let me = this;
			me.$ZcPublic.Server.Log('App.vue', 'onError', err.message);
		}
	}
</script> -->

<style>
	/*每个页面公共css */
	@import './common/uni.css';

	page {
		background: #F4F5F6;
		height: 100%;
		color: #4d4d4d;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		font-size: 28upx !important;
	}

	view {
		font-family: Microsoft YaHei;
	}
	.container {
		width: 100%;
		height: 100%;
	}

	/* view{font-size: 36upx!important;} */
	.zcFlex_row {
		flex-direction: row !important;
	}

	.zcFlex_column {
		flex-direction: column !important;
	}

	.zcJustifyC_center {
		justify-content: center !important;
	}

	.zcJustifyC_end {
		justify-content: flex-end !important;
	}

	.zcJustifyC_between {
		justify-content: space-between !important;
	}

	.zcJustifyC_start {
		justify-content: flex-start !important;
	}

	.zcAlignC_center {
		align-content: center !important;
	}

	.zcAlignC_end {
		align-content: flex-end !important;
	}

	.zcAlignC_between {
		align-content: space-between !important;
	}

	.zcAlignC_around {
		align-content: space-around !important;
	}

	.zcAlignI_center {
		align-items: center !important;
	}

	.zcAlignI_end {
		align-items: flex-end !important;
	}

	.zcAlignI_start {
		align-items: flex-start !important;
	}

	.zcFlex1,.flex1 {
		flex: 1 !important;
	}

	.zcOverflow3 {
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}

	.zcRelative {
		position: relative;
	}
/*自定义*/
.f-center,.f-side,.f-upDonwn,.flex,.itemCenter{
  display: flex;
}
.f-center,.f-side,.f-upDonwn,.itemCenter{
  align-items: center;
}
.f-side{
  justify-content: space-between;
}
.f-center,.f-upDonwn{
  justify-content: center;
}
.f-upDonwn{
  flex-direction: column;
}
.flexWrap{
flex-wrap:wrap
}

@font-face {
  font-family: 'iconfont';  /* project id 1487077 */
  src: url('//at.alicdn.com/t/font_1487077_tht2g0as8u.eot');
  src: url('//at.alicdn.com/t/font_1487077_tht2g0as8u.eot?#iefix') format('embedded-opentype'),
  url('//at.alicdn.com/t/font_1487077_tht2g0as8u.woff2') format('woff2'),
  url('//at.alicdn.com/t/font_1487077_tht2g0as8u.woff') format('woff'),
  url('//at.alicdn.com/t/font_1487077_tht2g0as8u.ttf') format('truetype'),
  url('//at.alicdn.com/t/font_1487077_tht2g0as8u.svg#iconfont') format('svg');
}

	.iconfont {
		font-family: "iconfont" !important;
		font-size: 28upx;
		font-style: normal;
		position: relative;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	.uni-icon-search:before {
		font-weight: bold;
	}

	.icon-xiasanjiaoxiangxiamianxing:before { //下拉箭头
		content: "\e906";
	}	
	.icon-you:before {  //向右箭头
		content: "\e778";
	}
  .icon-arrowleft:before {  //向左边箭头
		content: "\e614";
	}
	.icon-close:before { //首页打卡关闭
		content: "\e6c5";
	}
	.icon-down-trangle:before {  //向下
		content: "\e605";
	}
	.icon-sousuo1:before { //收缩首页
		content: "\e77e";
	}
.icon-sousuo2:before{ //扫一扫
	content: "\e64b";
}
.icon-tuichu:before{ //退出
	content: "\e600";
}
.icon-up2:before{ //向上收起
	content: "\e6a9";
}
.icon-bianji:before{ //编辑
	content: "\e601";
}
.icon-jia:before{  
	content: "\e604";
}
.icon-shouji:before{ //手机
	content: "\e6fa";
}
.icon-tanhao:before{ //个人中心叹号
	content: "\e689";
}
.icon-guanbi:before{ //关闭
	content: "\e74d";
}
.icon-xunhuan1:before{ //首页循环
	content: "\e632";
}
.icon-bianji1:before{ //编辑1
	content: "\e734";
}
.icon-shaixuan:before{ //筛选
	content: "\e602";
}
.icon-search:before{ //搜索
	content: "\e603";
}
.icon-rili:before{ //日期
	content: "\e630";
}
.icon-gouxuan:before{ //正方形勾选
	content: "\e624";
}
.icon-gouxuan11:before{ //圆形勾选
	content: "\e617";
}
.icon-bitian:before{  //必填
	content: "\e60f";
}
.icon-deleteCycle:before{  //删除周期
	content: "\e631";
}
.icon-changeMan:before{  //切换销售
	content: "\e608";
}
.icon-ver:before{  //版本
	content: "\e60a";
}
	button:after {
		border: none !important;
	}

	.uni-tab-bar-loading {
		margin-bottom: 104upx;
	}
		/* 无数据样式 */
			.uni-tab-bar-loading{text-align: center;margin: 0;}
	.no_model{position: relative;display: flex;flex-direction: column;align-items: center;padding: 0 160upx;padding-top: 100upx;}
	.no_text{font-size: 30upx;color: #999999;position: absolute;bottom: 28upx;}
</style>
